@never_ever
Hello,
Only one thread is able to draw onto a context, or rather the surface of a given context, note the documentation's warning about thread affinity. That said, somewhere from the main thread you should call swapBuffers to make your changes visible, this entails managing the double-buffering yourself. You should know when rendering is done, since you do that in your worker threads, so you can connect a signal from the worker(s) to the GUI to notify it when you've finished drawing the surface. You don't need to subclass the QThread class, instead extend QObject and move an instance of it to the worker thread and use it to do the rendering/other work for you (the so called worker object approach). I'm pretty sure that if you need to resize the window (like handling the resize event) at some point, you'll need to add a mutex to serialize access to your context, so when resizing is done there will be no rendering occurring at the same time from another thread, that you can do relatively simply with a single QMutex object. I hope this helps.
Kind regards.
|